package cn.iocoder.yudao.framework.base.common.bpm.bpmn;

import cn.hutool.extra.template.Template;
import cn.hutool.extra.template.TemplateConfig;
import cn.hutool.extra.template.engine.velocity.VelocityEngine;

import java.util.HashMap;
import java.util.Map;

/**
 * 无分支流程BPMN文件生成
 */
public class SimpleLinearBpmnGenerator {


    private static Template template = loadTemplate();

    static Template loadTemplate() {
        TemplateConfig config = new TemplateConfig();
        config.setResourceMode(TemplateConfig.ResourceMode.CLASSPATH);
        VelocityEngine engine = new VelocityEngine(config);
        Template template = engine.getTemplate("/template/SimpleLinearBPMN.vm");
        return template;
    }


    public static String generator(SimpleLinearBpmn dto) {

        Map<String, Object> map = new HashMap<>();
        map.put("processId", dto.getProcessId());
        map.put("processName", dto.getProcessName());
        map.put("nodes", dto.nodes);
        map.put("timestamp", System.currentTimeMillis());
        String content = template.render(map);

        return content;
    }



}
